/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package epam_java.telephone.database;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;


public class ConnectionBDFactory    {
    public static Connection  createConnection()
            throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException{
        Properties props = new Properties();
      FileInputStream in=null;
      try{
      in = new FileInputStream("database.properties");
      props.load(in);
      } catch (IOException ex){}
      finally{
      if(in!=null){
          try{
              in.close();
          } catch(IOException e){}
      }
      }
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      String host = props.getProperty("host");
      String login = props.getProperty("login");
      String password = props.getProperty("password");
       return DriverManager.getConnection(host, login, password);
    }
}

